﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ChucNang_Admin_Admin_ThemQuangCao : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //DataDSTableAdapters.DOITACTableAdapter ad = new DataDSTableAdapters.DOITACTableAdapter();
        //ddlDoiTac.DataSource = ad.DOITAC_LayTatCa();
        //ddlDoiTac.DataTextField = "TenDoiTac";
    }
    protected void btnThem_Click(object sender, EventArgs e)
    {
        try
        {
            int vitri = int.Parse(txtViTri.Text);
            int cao = int.Parse(txtCao.Text);
            int rong = int.Parse(txtRong.Text);
            int id_doitac = int.Parse(ddlDoiTac.SelectedValue);
            string duongdan = ConfigurationSettings.AppSettings["FLASH_FOLDER"].ToString();
            duongdan+= fuDuongDan.FileName;
            DataDSTableAdapters.QUANGCAOTableAdapter ad = new DataDSTableAdapters.QUANGCAOTableAdapter();
            int? kq=0;
            ad.QUANGCAO_Them(id_doitac, vitri, cao, rong, duongdan, ckHienThi.Checked, ref kq);
            if (fuDuongDan.FileName != "")
            {
                duongdan = ConfigurationSettings.AppSettings["FLASH_FOLDER"].ToString() + fuDuongDan.FileName;
                fuDuongDan.SaveAs(Server.MapPath(duongdan));

            }
            if (kq == 0)
                Response.Write("<script>alert('Thêm thành công'); location.href='Admin_QuanLyQuangCao.aspx'</script>");
            else
                Response.Write("<script>alert('Thêm thất bại. Xem lại vị trí, ví trí nhập vào có thể đã tồn tại! '); location.href='Admin_ThemQuangCao.aspx'</script>");

        }
        catch (System.Exception ex)
        {
        	
        }
    }
}
